<?php

/**
 * Persona form base class.
 *
 * @method Persona getObject() Returns the current form's model object
 *
 * @package    sibi-salud
 * @subpackage form
 * @author     SIBI <sibiud@gmail.com>
 */
abstract class BasePersonaForm extends BaseFormPropel
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'               => new sfWidgetFormInputHidden(),
      'documento_id'     => new sfWidgetFormPropelChoice(array('model' => 'Documento', 'add_empty' => true)),
      'identificacion'   => new sfWidgetFormInputText(),
      'nombres'          => new sfWidgetFormInputText(),
      'apellidos'        => new sfWidgetFormInputText(),
      'fecha_nacimiento' => new sfWidgetFormDate(),
      'email'            => new sfWidgetFormInputText(),
      'foto'             => new sfWidgetFormInputText(),
      'created_at'       => new sfWidgetFormDateTime(),
      'updated_at'       => new sfWidgetFormDateTime(),
    ));

    $this->setValidators(array(
      'id'               => new sfValidatorPropelChoice(array('model' => 'Persona', 'column' => 'id', 'required' => false)),
      'documento_id'     => new sfValidatorPropelChoice(array('model' => 'Documento', 'column' => 'id', 'required' => false)),
      'identificacion'   => new sfValidatorString(array('max_length' => 45, 'required' => false)),
      'nombres'          => new sfValidatorString(array('max_length' => 45)),
      'apellidos'        => new sfValidatorString(array('max_length' => 45)),
      'fecha_nacimiento' => new sfValidatorDate(array('required' => false)),
      'email'            => new sfValidatorString(array('max_length' => 45, 'required' => false)),
      'foto'             => new sfValidatorString(array('max_length' => 45, 'required' => false)),
      'created_at'       => new sfValidatorDateTime(array('required' => false)),
      'updated_at'       => new sfValidatorDateTime(array('required' => false)),
    ));

    $this->validatorSchema->setPostValidator(
      new sfValidatorPropelUnique(array('model' => 'Persona', 'column' => array('identificacion')))
    );

    $this->widgetSchema->setNameFormat('persona[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    parent::setup();
  }

  public function getModelName()
  {
    return 'Persona';
  }


}
